import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebPage3 extends StatefulWidget {
  const WebPage3({super.key});

  @override
  State<WebPage3> createState() => _WebPage3State();
}

class _WebPage3State extends State<WebPage3> {
  // 1
  late WebViewController controller;

  @override
  void initState() {
    super.initState();
    _initWebView();
  }

  _initWebView() async {
    // 2
    controller = WebViewController();
    // controller.loadRequest(Uri.parse("https://flutter.cn"));
    controller.loadFlutterAsset("assets/html/index.html");
  }

  @override
  Widget build(BuildContext context) {
    return WebViewWidget(controller: controller);
  }
}
